<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<img id="hl" src="img/off.gif"><br>
<div class="cls">热血传奇</div>
<div class="cls">无敌剑圣</div>

<input type="checkbox" name="hobby">电影
<input type="checkbox" name="hobby">旅游
<input type="checkbox" name="hobby">游戏
</body>
<script>
    //1.点亮灯泡
    /* var imgs = document.getElementsByTagName('img');
     img = imgs[0];*/
    img = document.getElementById('hl');
    img.src = "img/on.gif";
    //2.将所有div标签内容后加上:very good(红色)
    var divs = document.getElementsByTagName('div');
    for (let i = 0; i < divs.length; i++) {
        const div = divs[i];/*使用const,原来的值不会修改*/
        div.innerHTML += '<font color="red">very good!</font>';
        /*innerHTML跟innerTEXT之间的区别,前者可以识别html标签*/
    }
    //3.使所有的复选框(checkbox)呈现选中状态
    var checks = document.getElementsByName('hobby');
    for (let i = 0; i < checks.length; i++) {
        const check = checks[i];
        check.checked = true;
    }
</script>
</html>